package com.hehe.boot.controller;

import com.hehe.boot.pojo.AdminHttp.AdminRegisterRequest;
import com.hehe.boot.pojo.Result;
import com.hehe.boot.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @PostMapping("/register")
    public Result<Map<String,Long>> Register(@RequestBody AdminRegisterRequest adminRegisterRequest){
        Long adminId = adminService.register(adminRegisterRequest.getUsername(),adminRegisterRequest.getPassword());
        Map<String,Long> map = new HashMap<>();
        map.put("AdminId",adminId);
        return Result.success(map);
    }


}
